
import { User } from "../../../modeal/user.js"
const user = new User()
Page({

  data: {
    lists: [
      { id: 1, name: '优惠券', isTabBar: false, icon: '../../images/user/toyhuijuan.png', path: "/pages/user/coupon/coupon" },
      { id: 2, name: '我的代言', isTabBar: false, icon: '../../images/user/daiyan.png', path: "/pages/user/represent/represent" },
      { id: 3, name: '我的订单', isTabBar: true, icon: '../../images/user/order.png', path: "/pages/user/myOrder/index/index" },
      { id: 4, name: '我的地址', isTabBar: false, icon: '../../images/user/site.png', path: "/pages/user/site/index/index" }
    ],
    userInfo: {},
    baseConfig: {}

  },

  onLoad: function (options) {
    let userInfo = wx.getStorageSync('userinfo');
    let baseConfig = wx.getStorageSync('baseConfig');
    this.setData({ baseConfig, userInfo })
  },

  onReady: function () { },
  onShow: function () { },
  onPullDownRefresh: function () { },

  // go Admin
  goAdmin () {
    wx.navigateTo({ url: '/pages/admin/index/index' })
  },

  goBlance () {
    wx.navigateTo({ url: '/pages/user/recharge/recharge' })
  },

  goIntegral () {
    wx.switchTab({ url: "/pages/integralShop/index/index" })

  },

  goList (e) {
    let current = e.currentTarget.dataset.item
    let url = current.path
    current.isTabBar ? wx.switchTab({ url }) : '';
    current.id == 2 ? this.getSpokesmanInfo({ url }) : wx.navigateTo({ url })
  },

  // 获的代言人基本信息 
  getSpokesmanInfo (url) {
    user.getSpokesmanInfo().then(res => {
      wx.setStorageSync('spokesmanInfo', res)
      wx.navigateTo({ url: "/pages/user/represent/represent" })
    })
  },



})